#include <gtk/gtk.h>
#include <stdio.h>
#include <string.h>
#include <time.h>

static void destroy(GtkWidget* w, gpointer* d)
{
        gtk_main_quit();
}

static gboolean update_time(gpointer* data)
{
        GtkLabel* label = (GtkLabel*)data;
        
        time_t mytime;
        mytime = time(NULL);
        char* time_string = ctime(&mytime)+11; 
        time_string[5]='\0';
        gtk_label_set_label(GTK_LABEL(label), time_string);
        return TRUE;
}

static gboolean button_press(GtkWidget* w, GdkEventButton* event, gpointer* d)
{
        static gboolean decorated = TRUE;
        if (event->type == GDK_BUTTON_PRESS){
                if (event->button == 3){
                        decorated = ! decorated;
                        gtk_window_set_decorated((GtkWindow*)w, decorated);
                       }
         }
}


int main(int argc, char* argv[])
{
        gtk_init(&argc, &argv);
        GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        GtkWidget* label = gtk_label_new("");
        gtk_container_add(GTK_CONTAINER(window), label);
        update_time((gpointer*)label);

        gtk_window_set_default_size(GTK_WINDOW(window),90,32);
        gtk_window_set_title(GTK_WINDOW(window)," ");
        gtk_widget_add_events(window, GDK_BUTTON_PRESS_MASK);
        g_signal_connect(window, "destroy", G_CALLBACK(destroy), NULL);
        g_signal_connect(window, "button-press-event",G_CALLBACK(button_press),NULL);
        g_timeout_add_seconds(1, (GSourceFunc) update_time, (gpointer) label);

        gtk_widget_show_all(window);
        gtk_main();
        return 0;
}

